<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>使用 pow() 方法</title>
</head>
<body>
<script>
    function fix(fixNumber, decimalPlaces) {
        var div = Math.pow(10, decimalPlaces);
        fixNumber = Math.round(fixNumber * div) / div;
        return fixNumber;
    }

    var number1 = prompt('Enter the number with decimal places you want to fix', '');
    var number2 = prompt('How many decimal places do you want?', '');
    document.write(number1 + ' fixed to ' + number2 + ' decimal places is: ');
    document.write(fix(number1, number2));
</script>
</body>
</html>